package com.easy.cms.material.service.impl;

import com.easy.cms.base.CommonResult;
import com.easy.cms.material.model.Organization;
import com.easy.cms.material.repository.OrganizationRepository;
import com.easy.cms.material.service.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class OrganizationServiceImpl implements OrganizationService {
    @Autowired
    private OrganizationRepository organizationRepository;

    @Override
    public CommonResult<List<Organization>> listPage() {
        return CommonResult.success(organizationRepository.findAll());
    }

    @Override
    public CommonResult<?> getOrganizationInfo() {
        // 可根据实际需求完善逻辑
        return CommonResult.success(null);
    }

    @Override
    public CommonResult<List<Organization>> searchOrganization() {
        // 可根据实际需求完善逻辑
        return CommonResult.success(organizationRepository.findAll());
    }

    @Override
    public CommonResult<?> addOrganization(Organization organization) {
        return CommonResult.success(organizationRepository.save(organization));
    }

    @Override
    public CommonResult<?> updateOrganization(Organization organization) {
        return CommonResult.success(organizationRepository.save(organization));
    }

    @Override
    public CommonResult<?> deleteOrganization(Long id) {
        organizationRepository.deleteById(id);
        return CommonResult.success(null);
    }
}